﻿Imports Mystery

Public Class ContentLabel
    Implements IContentModificationsSubriver

    Private _content As IContent

    Public Sub New(content As IContent)
        Me.InitializeComponent()

        _content = content
        getGlobalObject(Of ContentModifications).subscrive(me)

    End Sub

    Public Sub notificate() Implements Mystery.IContentModificationsSubriver.notificate
        If _content Is Nothing Then Exit Sub
        'refresh 
        _content = getGlobalObject(Of IContentDispatcher).getContent(Of IContent)(_content.guid)

        Me.Dispatcher.Invoke(Sub()
                                 If _content Is Nothing Then
                                     Me.Content = Nothing
                                 Else
                                     Dim ref_text As ReferenceText = _content.GetType.getFirstAttribute(Of ReferenceText)()
                                     If ref_text IsNot Nothing Then
                                         Me.Content = ref_text.getReferenceText(_content)
                                     Else
                                         Me.Content = _content.guid.ToString
                                     End If
                                 End If

                             End Sub)
    End Sub

    Public ReadOnly Property subscribed As Mystery.IContent Implements Mystery.IContentModificationsSubriver.subscribed
        Get
            Return _content
        End Get
    End Property
End Class
